﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccess
{
    public class StoreDataAccess
    {
        public static void InsertNewStore(Model.ProductStore store)
        {
            SSDDEntities.Instance.DiscardChanges();
            SSDDEntities.Instance.ProductStores.Add(store);
            SSDDEntities.Instance.SaveChanges();
        }

        public static void ModifyNewStore(Model.ProductStore store)
        {
            SSDDEntities.Instance.DiscardChanges();
            var q = (from s in SSDDEntities.Instance.ProductStores
                     where s.StoreId == store.StoreId
                     select s).First();
            q.ProductId = store.ProductId;
            q.StoreEnterDate = store.StoreEnterDate;
            q.StorePriceByUnit = store.StorePriceByUnit;
            q.StoreQuantity = store.StoreQuantity;
            SSDDEntities.Instance.SaveChanges();

        }

        public static List<Model.ProductStore> GetStores { get { return SSDDEntities.Instance.ProductStores.ToList(); } }
    }
}
